//
//  CCMyLayer.m
//  newFinding
//
//  Created by Shin Stupid on 7/26/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "CCMyLayer.h"

@implementation CCMyLayer
#pragma mark ----------------------------------------------------------------------------
#pragma mark is Inside ?
//-(BOOL) isInsidePointOnRect:( CGPoint)rect at:( CGPoint)check_pt
//{
//	BOOL ret = NO;
//	
//	if( (rect.origin.x <= check_pt.x)
//	   && ((rect.origin.x+rect.size.width ) >= check_pt.x)
//	   && ( rect.origin.y                   <= check_pt.y)
//	   && ((rect.origin.y+rect.size.height) >= check_pt.y)
//	   )
//	{
//		ret = YES;
//        NSLog(@"is Touch Inside");
//	}
//	return ret;
//}

-(BOOL) isInsidePointOnRect:( CCSprite *)rect at:( CGPoint)check_pt
{
	BOOL ret = NO;
	
	if( (rect.position.x <= check_pt.x)
	   && ((rect.position.x+rect.textureRect.size.width ) >= check_pt.x)
	   && ( rect.position.y                   <= check_pt.y)
	   && ((rect.position.y+rect.textureRect.size.height) >= check_pt.y)
	   )
	{
		ret = YES;
        NSLog(@"is Touch Inside");
	}
	return ret;
}

#pragma mark ----------------------------------------------------------------------------
#pragma mark ADD_SPRITES
-(CCSprite*)DrawImageSpritebyLayer:(CCLayer*)myLayer andFileName:(NSString *)strName atPosition:(CGPoint)P withZ:(int)iZ andScale:(float)fScale
{
	CCSprite *item =[CCSprite spriteWithFile:strName];
	[item setAnchorPoint:ccp(0, 0)];
	[item setPosition:P];	
	if(fScale>0)
	{
		[item setScale:fScale];
	}
    
	if(iZ!=0)
	{
		[myLayer addChild:item z:iZ];
		
	}
	else {
		[myLayer addChild:item];
		
	}
    
	return item;
}
-(void)changePageWithScene:(CCScene *)changeScene type:(int)N andDuraton:(float)duration
{
	switch (N) {
		case 1:
			/// slide right
			[[CCDirector sharedDirector] replaceScene:[SlideInLeftAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 2:
			/// slide left			
			[[CCDirector sharedDirector] replaceScene:[SlideInRightAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 3:
			/// fade up 
			[[CCDirector sharedDirector] replaceScene:[FadeUpAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 4:
			/// fade Down 
			[[CCDirector sharedDirector] replaceScene:[FadeDownAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 5:
			/// Page Turn
			[[CCDirector sharedDirector] replaceScene:[PageTurnAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 6:
			/// Flip X
			[[CCDirector sharedDirector] replaceScene:[FlipXAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 7:
			/// Flip Y
			[[CCDirector sharedDirector] replaceScene:[FlipYAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 8:
			/// Shrink Grow
			[[CCDirector sharedDirector] replaceScene:[ShrinkGrowAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 9:
			//CrossFade
			[[CCDirector sharedDirector] replaceScene:[CrossFadeAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 10:
			//RadialCCW
			[[CCDirector sharedDirector] replaceScene:[FadeBLAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 11:
			//TurnOffTiles
			[[CCDirector sharedDirector] replaceScene:[TurnOffTilesAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 12:
			//ZoomFlipAngular
			[[CCDirector sharedDirector] replaceScene:[ZoomFlipAngularAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 13:
			//ZoomFlipX
			[[CCDirector sharedDirector] replaceScene:[ZoomFlipXAnimation transitionWithDuration:duration scene:changeScene]];
			break;
		case 14:
			//ZoomFlipY
			[[CCDirector sharedDirector] replaceScene:[ZoomFlipYAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
		case 15:
			//Normal
			[[CCDirector sharedDirector] replaceScene:changeScene];
            
			
			break;
        case 16:
			//FadeBL
			
            [[CCDirector sharedDirector] replaceScene:[FadeBLAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 17:
			//FadeTR
			[[CCDirector sharedDirector] replaceScene:[FadeTRAnimation transitionWithDuration:duration scene:changeScene]];
            
			
			break;
        case 18:
			//FlipAngular
			
            [[CCDirector sharedDirector] replaceScene:[FlipAngularAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 19:
			//JumpZoom
			
             [[CCDirector sharedDirector] replaceScene:[JumpZoomAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 20:
			//MoveInB
			 [[CCDirector sharedDirector] replaceScene:[MoveInBAnimation transitionWithDuration:duration scene:changeScene]];
            
			
			break;
        case 21:
			//MoveInL
			[[CCDirector sharedDirector] replaceScene:[MoveInLAnimation transitionWithDuration:duration scene:changeScene]];
            
			
			break;
        case 22:
			//MoveInR
			
            [[CCDirector sharedDirector] replaceScene:[MoveInRLAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 23:
			//MoveInT
			
             [[CCDirector sharedDirector] replaceScene:[MoveInTAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 24:
			//Progress
			
           // [[CCDirector sharedDirector] replaceScene:[ProgressAnimation transitionWithDuration:3.0f scene:changeScene]];
			//error
			break;
        case 25:
			//ProgressHorizontalAnimation
			
             [[CCDirector sharedDirector] replaceScene:[ProgressHorizontalAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 26:
			//ProgressInOut
			
             [[CCDirector sharedDirector] replaceScene:[ProgressInOutAnimation transitionWithDuration:duration scene:changeScene]];
			
			break;
        case 27:
			//ProgressOutIn
			[[CCDirector sharedDirector] replaceScene:[ProgressOutInAnimation transitionWithDuration:duration scene:changeScene]];
            
			
			break;
        case 28:
			//ProgressRadialCCW
			[[CCDirector sharedDirector] replaceScene:[ProgressRadialCCWAnimation transitionWithDuration:duration scene:changeScene]];
            
			
			break;
            case 29:
            //ProgressRadialCW
            [[CCDirector sharedDirector] replaceScene:[ProgressRadialCWAnimation transitionWithDuration:duration scene:changeScene]];
            break;
        case 30:
            //ProgressVertical
            [[CCDirector sharedDirector] replaceScene:[ProgressVerticalAnimation transitionWithDuration:duration scene:changeScene]];
            break;
        case 31:
            //RotoZoom
            [[CCDirector sharedDirector] replaceScene:[RotoZoomAnimation transitionWithDuration:duration scene:changeScene]];
            break;
        case 32:
            //SplitCols
            [[CCDirector sharedDirector] replaceScene:[SplitColsAnimation transitionWithDuration:duration scene:changeScene]];
            break;
        case 33:
            //SplitRows
             [[CCDirector sharedDirector] replaceScene:[SplitRowsAnimation transitionWithDuration:duration scene:changeScene]];
            break;
			
		default:
			break;
	}
}
#pragma mark ----------------------------------------------------------------------------
-(CCFiniteTimeAction *) getActionSequence: (NSMutableArray *) actions
{
	CCFiniteTimeAction *seq = nil;
	for (CCFiniteTimeAction *anAction in actions)
	{
		if (!seq)
		{
			seq = anAction;
		}
		else
		{
			seq = [CCSequence actionOne:seq two:anAction];
		}
	}
	return seq ;
	
}
//#pragma mark NEW_METHOD
//-(AnimationClass*)addImageAnimationByClass:(Class)tempClass withZ:(int)iZ
//{
//	AnimationClass* _itemClass=[[[tempClass alloc] initWithParent:self withZ:iZ] autorelease];
//	
//	return _itemClass;
//}
//
//
//






@end
